//
//  AppDelegate.m
//  geiTA
//
//  Created by 曲丹阳 on 14-11-19.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "AppDelegate.h"
#import "HomeViewController.h"
#import "FindViewController.h"
#import "DateViewController.h"
#import "MineViewController.h"
#import <ShareSDK/ShareSDK.h>
#import "WeiboSDK.h"
#import "WeiboApi.h"
#import "WXApi.h"
#import <TencentWeiboConnection/TencentWeiboConnection.h>


@interface AppDelegate ()<WXApiDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
    [ShareSDK registerApp:@"iosv1101"];

    //添加新浪微博应用 注册网址 http://open.weibo.com
    [ShareSDK connectSinaWeiboWithAppKey:@"568898243"
                               appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
                             redirectUri:@"http://www.sharesdk.cn"];
    //当使用新浪微博客户端分享的时候需要按照下面的方法来初始化新浪的平台
    [ShareSDK  connectSinaWeiboWithAppKey:@"568898243"
                                appSecret:@"38a4f8204cc784f81f9f0daaf31e02e3"
                              redirectUri:@"http://www.sharesdk.cn"
                              weiboSDKCls:[WeiboSDK class]];
    
    //添加腾讯微博应用 注册网址 http://dev.t.qq.com
    [ShareSDK connectTencentWeiboWithAppKey:@"801307650"
                                  appSecret:@"ae36f4ee3946e1cbb98d6965b0b2ff5c"
                                redirectUri:@"http://www.sharesdk.cn"
                                   wbApiCls:[WeiboApi class]];
    

    //添加Facebook应用  注册网址 https://developers.facebook.com
    [ShareSDK connectFacebookWithAppKey:@"107704292745179"
                              appSecret:@"38053202e1a5fe26c80c753071f0b573"];
    
    //添加Twitter应用  注册网址  https://dev.twitter.com
    [ShareSDK connectTwitterWithConsumerKey:@"mnTGqtXk0TYMXYTN7qUxg"
                             consumerSecret:@"ROkFqr8c3m1HXqS3rm3TJ0WkAJuwBOSaWhPbZ9Ojuc"
                                redirectUri:@"http://www.sharesdk.cn"];
    /**
     连接豆瓣应用以使用相关功能，此应用需要引用DouBanConnection.framework
     http://developers.douban.com上注册豆瓣社区应用，并将相关信息填写到以下字段
     **/
    [ShareSDK connectDoubanWithAppKey:@"02e2cbe5ca06de5908a863b15e149b0b"
                            appSecret:@"9f1e7b4f71304f2f"
                          redirectUri:@"http://www.sharesdk.cn"];

    //连接邮件
    [ShareSDK connectMail];
    
    //连接打印
    [ShareSDK connectAirPrint];
    
    //连接拷贝
    [ShareSDK connectCopy];

  
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds ]];
    [_window setBackgroundColor:[UIColor whiteColor]];
    [_window makeKeyAndVisible];
    
    
    
    
#pragma mark -
#pragma mark 首页
    HomeViewController *home = [[HomeViewController alloc]init];
    UINavigationController *homeNav = [[UINavigationController alloc]initWithRootViewController:home];
    [homeNav.navigationBar setBarTintColor:[UIColor brownColor]];
    homeNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:nil selectedImage:nil];
    
    
   
#pragma mark -
#pragma mark 纪念日
    DateViewController *date =[[DateViewController alloc]init];
    UINavigationController *dateNav=[[UINavigationController alloc]initWithRootViewController:date];
    [dateNav.navigationBar setBarTintColor:[UIColor brownColor]];
    dateNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"纪念日" image:nil
                                                  selectedImage:nil];
    
    
#pragma mark -
#pragma mark 我的
    MineViewController *mine =[[MineViewController alloc]init];
    UINavigationController *mineNav=[[UINavigationController alloc]initWithRootViewController:mine];
    [mineNav.navigationBar setBarTintColor:[UIColor brownColor]];
    mineNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:nil
                                              selectedImage:nil];
#pragma mark -
#pragma mark 发现
    FindViewController *find =[[FindViewController alloc]init];
    UINavigationController *findNav=[[UINavigationController alloc]initWithRootViewController:find];
    [findNav.navigationBar setBarTintColor:[UIColor brownColor]];
    findNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"发现" image:nil
                                              selectedImage:nil];

    
    
    
    
    NSMutableArray *array = [NSMutableArray arrayWithObjects:homeNav, dateNav, mineNav, findNav, nil];
    UITabBarController *tab = [[UITabBarController alloc]init];
    [tab setViewControllers:array animated:YES];
    [tab.tabBar setTintColor:[UIColor whiteColor]];
    [tab.tabBar setBarTintColor:[UIColor brownColor]];
    
    [_window setRootViewController:tab];
    
    [home release];
    [homeNav release];
    [date release];
    [dateNav release];
    [mine release];
    [mineNav release];
    [find release];
    [findNav release];
    [tab release];
    [_window release];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [ShareSDK handleOpenURL:url wxDelegate:self];
}
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:self];
}

#pragma mark - WXAidelegate

-(void)onReq:(BaseReq *)req
{
    
}
-(void)onResp:(BaseResp *)resp
{
    
}

@end
